﻿<%@ Page Language="C#" AutoEventWireup="true" MasterPageFile="~/Popup.Master" CodeBehind="rptViewer.aspx.cs"
    Inherits="VSM.rptViewer" %>

<%@ Register assembly="CrystalDecisions.Web, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304" namespace="CrystalDecisions.Web" tagprefix="CR" %>

<%@ Register assembly="Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" namespace="Microsoft.Reporting.WebForms" tagprefix="rsweb" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <script type="text/javascript">
        function turnBack() {

            var type = '<%= Session["DocumentType"]%>';
            var siteName = "";
            switch (type) {
                case "QT":
                    siteName = "P_Quotation";
                    break;
                case "RO":
                    siteName = "P_JobCard";
                    break;
                case "PO":
                    siteName = "P_PartOrder";
                    break;
                case "RS":
                    siteName = "ReceptionSheet";
                    break;
                case "QI":
                    siteName = "QuickInspection";
                    break;
                case "WS":
                    siteName = "P_WSCA";
                    break;
                case "WB":
                    siteName = "WSCB";
                    break;
                case "PQR":
                    siteName = "P_PQR";
                    break;
                case "RES":
                    siteName = "P_Reservation";
                case "SH":
                    siteName = "ServiceHistory";
                    break;
            }

            var url = siteName + ".aspx?type=" + type + "&GeneralID=" + document.getElementById('hf_GeneralID').value;
            var urlRES = "P_Reservation.aspx?type=" + type + "&ResID=" + document.getElementById('hf_ResID').value;
            var urlSH = "ServiceHistory.aspx?VIN="+document.getElementById('hf_VIN').value;
            if (type == "RES")
                window.open(urlRES, '_self');
            else if (type == "SH")
                window.open(urlSH, '_self');
            else
                window.open(url, '_self');
        }
    </script>

    <asp:UpdatePanel ID="updatePanel" runat="server" UpdateMode="Conditional">
        <ContentTemplate>

                <asp:Button ID="btnBack" runat="server" OnClientClick="turnBack();"  Text="Back" 
                    Width="74px" />
                <asp:Button ID="btnPrint" runat="server" onclick="btnPrint_Click" Text="Print" 
                    Width="74px" />
                <asp:HiddenField ID="hf_GeneralID" runat="server" ClientIDMode="Static" />
                <asp:HiddenField ID="hf_ResID" runat="server" ClientIDMode="Static" />
                <asp:HiddenField ID="hf_VIN" runat="server" ClientIDMode="Static" />
                <CR:CrystalReportViewer ID="CrystalReportViewer1" runat="server" 
                    AutoDataBind="true" EnableDrillDown="False" 
                    GroupTreeStyle-ShowLines="False" HasCrystalLogo="False" 
                    HasDrillUpButton="False" HasRefreshButton="True" 
                    HasToggleGroupTreeButton="False" Height="50px" PrintMode="ActiveX" 
                    Width="350px" />
                
        </ContentTemplate>
    </asp:UpdatePanel>

</asp:Content>
